How to replace {tag_INDEX} with array[INDEX] element
Posted
by ekapek
on Stack Overflow
See other posts from Stack Overflow
or by ekapek
Published on 2010-05-25T09:42:52Z
Indexed on
2010/05/25
9:51 UTC
Read the original article
Hit count: 194
Hi,
I have string like this;
"String {tag_0} text {tag_2} and {tag_1}"
Now i need to replace all {tag_INDEX} with elements from array
$myArray = array('a','b','c');
so after replacement it should looks like:
"String a text c and b"
What is the best way to do this? I'm trying with preg_replace and preg_replace_callback but without any good results
© Stack Overflow or respective owner